<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form label-width="72px" @keyup.enter="search" inline>
      <el-form-item label="所属公司">
        <TenantChoose
          @loaded="search"
          v-model="form.tenant_id"
          :multiple="false"
        />
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { useFormData } from '@/utils/use-form-data';
  const emit = defineEmits(['search']);
  import { watch } from 'vue';

  /** 表单数据 */
  const [form] = useFormData({
    tenant_id: 0
  });

  /** 搜索 */
  const search = () => {
    emit('search', { ...form });
  };
  watch(
    () => form.tenant_id,
    (val) => {
      if (val) {
        search(); // tenant_id 设置后再请求
      }
    }
  );
</script>
